<template>
  <el-dialog v-model="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
    <el-form :model="dataForm" :rules="rules" ref="dataFormRef" @keyup.enter="dataFormSubmitHandle()" label-width="120px">
      <el-form-item label="code" prop="exhCode">
        <el-input v-model="dataForm.exhCode" placeholder="code"></el-input>
      </el-form-item>
      <el-form-item label="managerid" prop="exbManagerId">
        <el-input v-model="dataForm.exbManagerId" placeholder="managerid"></el-input>
      </el-form-item>
      <el-form-item label="type" prop="exhType">
        <el-input v-model="dataForm.exhType" placeholder="type"></el-input>
      </el-form-item>
      <el-form-item label="ifcompany" prop="exhIfCompany">
        <el-input v-model="dataForm.exhIfCompany" placeholder="ifcompany"></el-input>
      </el-form-item>
      <el-form-item label="group" prop="exhGroup">
        <el-input v-model="dataForm.exhGroup" placeholder="group"></el-input>
      </el-form-item>
      <el-form-item label="qtrid" prop="qtrId">
        <el-input v-model="dataForm.qtrId" placeholder="qtrid"></el-input>
      </el-form-item>
      <el-form-item label="展会名称" prop="exhName">
        <el-input v-model="dataForm.exhName" placeholder="展会名称"></el-input>
      </el-form-item>
      <el-form-item label="是否确定" prop="exhIfConfirm">
        <el-input v-model="dataForm.exhIfConfirm" placeholder="是否确定"></el-input>
      </el-form-item>
      <el-form-item label="开始时间" prop="exhBTime">
        <el-input v-model="dataForm.exhBTime" placeholder="开始时间"></el-input>
      </el-form-item>
      <el-form-item label="结束时间" prop="exhETime">
        <el-input v-model="dataForm.exhETime" placeholder="结束时间"></el-input>
      </el-form-item>
      <el-form-item label="城市" prop="exhCity">
        <el-input v-model="dataForm.exhCity" placeholder="城市"></el-input>
      </el-form-item>
      <el-form-item label="场馆id" prop="exhEhcId">
        <el-input v-model="dataForm.exhEhcId" placeholder="场馆id"></el-input>
      </el-form-item>
      <el-form-item label="详细介绍" prop="exhDetail">
        <el-input v-model="dataForm.exhDetail" placeholder="详细介绍"></el-input>
      </el-form-item>
      <el-form-item label="展品范围" prop="exhScope">
        <el-input v-model="dataForm.exhScope" placeholder="展品范围"></el-input>
      </el-form-item>
      <el-form-item label="所属行业" prop="exhTrade">
        <el-input v-model="dataForm.exhTrade" placeholder="所属行业"></el-input>
      </el-form-item>
      <el-form-item label="所属行业1" prop="exhTrade1">
        <el-input v-model="dataForm.exhTrade1" placeholder="所属行业1"></el-input>
      </el-form-item>
      <el-form-item label="预计展会面积" prop="exhAcreage">
        <el-input v-model="dataForm.exhAcreage" placeholder="预计展会面积"></el-input>
      </el-form-item>
      <el-form-item label="联系进展" prop="charProcess">
        <el-input v-model="dataForm.charProcess" placeholder="联系进展"></el-input>
      </el-form-item>
      <el-form-item label="展会网址" prop="exhWebUrl">
        <el-input v-model="dataForm.exhWebUrl" placeholder="展会网址"></el-input>
      </el-form-item>
      <el-form-item label="观众数量" prop="intCustNumber">
        <el-input v-model="dataForm.intCustNumber" placeholder="观众数量"></el-input>
      </el-form-item>
      <el-form-item label="recommend" prop="exhRecommend">
        <el-input v-model="dataForm.exhRecommend" placeholder="recommend"></el-input>
      </el-form-item>
      <el-form-item label="优先级" prop="exhPriority">
        <el-input v-model="dataForm.exhPriority" placeholder="优先级"></el-input>
      </el-form-item>
      <el-form-item label="联系信息" prop="exhLinkInfo">
        <el-input v-model="dataForm.exhLinkInfo" placeholder="联系信息"></el-input>
      </el-form-item>
      <el-form-item label="组织信息" prop="exhOrgInfo">
        <el-input v-model="dataForm.exhOrgInfo" placeholder="组织信息"></el-input>
      </el-form-item>
      <el-form-item label="销售情况" prop="exhExtInfo">
        <el-input v-model="dataForm.exhExtInfo" placeholder="销售情况"></el-input>
      </el-form-item>
      <el-form-item label="初始信息添加人" prop="exhCreator">
        <el-input v-model="dataForm.exhCreator" placeholder="初始信息添加人"></el-input>
      </el-form-item>
      <el-form-item label="短的展会名称" prop="exhSName">
        <el-input v-model="dataForm.exhSName" placeholder="短的展会名称"></el-input>
      </el-form-item>
      <el-form-item label="英文名称" prop="exhEName">
        <el-input v-model="dataForm.exhEName" placeholder="英文名称"></el-input>
      </el-form-item>
      <el-form-item label="创建时间" prop="exhCreateTime">
        <el-input v-model="dataForm.exhCreateTime" placeholder="创建时间"></el-input>
      </el-form-item>
      <el-form-item label="handletime" prop="exhHandleTime">
        <el-input v-model="dataForm.exhHandleTime" placeholder="handletime"></el-input>
      </el-form-item>
      <el-form-item label="ifaudited" prop="exhIfAudited">
        <el-input v-model="dataForm.exhIfAudited" placeholder="ifaudited"></el-input>
      </el-form-item>
      <el-form-item label="点击数" prop="exhClickNum">
        <el-input v-model="dataForm.exhClickNum" placeholder="点击数"></el-input>
      </el-form-item>
      <el-form-item label="最近一月访问次数" prop="exhNumLastMonth">
        <el-input v-model="dataForm.exhNumLastMonth" placeholder="最近一月访问次数"></el-input>
      </el-form-item>
      <el-form-item label="最近一周访问次数" prop="exhNumLastWeek">
        <el-input v-model="dataForm.exhNumLastWeek" placeholder="最近一周访问次数"></el-input>
      </el-form-item>
      <el-form-item label="此次展会在未开展会中的排名" prop="exhOrder">
        <el-input v-model="dataForm.exhOrder" placeholder="此次展会在未开展会中的排名"></el-input>
      </el-form-item>
      <el-form-item label="zhichinum" prop="exhZhichiNum">
        <el-input v-model="dataForm.exhZhichiNum" placeholder="zhichinum"></el-input>
      </el-form-item>
      <el-form-item label="fanduinum" prop="exhFanduiNum">
        <el-input v-model="dataForm.exhFanduiNum" placeholder="fanduinum"></el-input>
      </el-form-item>
      <el-form-item label="lastexhid" prop="exhLastExhId">
        <el-input v-model="dataForm.exhLastExhId" placeholder="lastexhid"></el-input>
      </el-form-item>
      <el-form-item label="exhStallNum" prop="exhStallNum">
        <el-input v-model="dataForm.exhStallNum" placeholder="exhStallNum"></el-input>
      </el-form-item>
      <el-form-item label="exhAttend" prop="exhAttend">
        <el-input v-model="dataForm.exhAttend" placeholder="exhAttend"></el-input>
      </el-form-item>
      <el-form-item label="exhSubPlace" prop="exhSubPlace">
        <el-input v-model="dataForm.exhSubPlace" placeholder="exhSubPlace"></el-input>
      </el-form-item>
      <el-form-item label="exhProject" prop="exhProject">
        <el-input v-model="dataForm.exhProject" placeholder="exhProject"></el-input>
      </el-form-item>
      <el-form-item label="exhMaxCurrentCard" prop="exhMaxCurrentCard">
        <el-input v-model="dataForm.exhMaxCurrentCard" placeholder="exhMaxCurrentCard"></el-input>
      </el-form-item>
      <el-form-item label="exhParentId" prop="exhParentId">
        <el-input v-model="dataForm.exhParentId" placeholder="exhParentId"></el-input>
      </el-form-item>
      <el-form-item label="exhShowRooms" prop="exhShowRooms">
        <el-input v-model="dataForm.exhShowRooms" placeholder="exhShowRooms"></el-input>
      </el-form-item>
      <el-form-item label="exhIfVisit" prop="exhIfVisit">
        <el-input v-model="dataForm.exhIfVisit" placeholder="exhIfVisit"></el-input>
      </el-form-item>
      <el-form-item label="exhRemark" prop="exhRemark">
        <el-input v-model="dataForm.exhRemark" placeholder="exhRemark"></el-input>
      </el-form-item>
      <el-form-item label="modifierId" prop="modifierId">
        <el-input v-model="dataForm.modifierId" placeholder="modifierId"></el-input>
      </el-form-item>
      <el-form-item label="exhOwner" prop="exhOwner">
        <el-input v-model="dataForm.exhOwner" placeholder="exhOwner"></el-input>
      </el-form-item>
      <el-form-item label="exhInviteActorOjaId" prop="exhInviteActorOjaId">
        <el-input v-model="dataForm.exhInviteActorOjaId" placeholder="exhInviteActorOjaId"></el-input>
      </el-form-item>
      <el-form-item label="exhEsName" prop="exhEsName">
        <el-input v-model="dataForm.exhEsName" placeholder="exhEsName"></el-input>
      </el-form-item>
      <el-form-item label="exhActorManagerId" prop="exhActorManagerId">
        <el-input v-model="dataForm.exhActorManagerId" placeholder="exhActorManagerId"></el-input>
      </el-form-item>
      <el-form-item label="exhDetailEn" prop="exhDetailEn">
        <el-input v-model="dataForm.exhDetailEn" placeholder="exhDetailEn"></el-input>
      </el-form-item>
      <el-form-item label="exhMarOfficerId" prop="exhMarOfficerId">
        <el-input v-model="dataForm.exhMarOfficerId" placeholder="exhMarOfficerId"></el-input>
      </el-form-item>
      <el-form-item label="code" prop="code">
        <el-input v-model="dataForm.code" placeholder="code"></el-input>
      </el-form-item>
      <el-form-item label="project" prop="project">
        <el-input v-model="dataForm.project" placeholder="project"></el-input>
      </el-form-item>
      <el-form-item label="exhFName" prop="exhFName">
        <el-input v-model="dataForm.exhFName" placeholder="exhFName"></el-input>
      </el-form-item>
      <el-form-item label="exhSaleAmount" prop="exhSaleAmount">
        <el-input v-model="dataForm.exhSaleAmount" placeholder="exhSaleAmount"></el-input>
      </el-form-item>
      <el-form-item label="exhActorCount" prop="exhActorCount">
        <el-input v-model="dataForm.exhActorCount" placeholder="exhActorCount"></el-input>
      </el-form-item>
      <el-form-item label="exhBoothCount" prop="exhBoothCount">
        <el-input v-model="dataForm.exhBoothCount" placeholder="exhBoothCount"></el-input>
      </el-form-item>
    </el-form>
    <template v-slot:footer>
      <el-button @click="visible = false">{{ $t("cancel") }}</el-button>
      <el-button type="primary" @click="dataFormSubmitHandle()">{{ $t("confirm") }}</el-button>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue";
import baseService from "@/service/baseService";
import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus";
const { t } = useI18n();
const emit = defineEmits(["refreshDataList"]);

const visible = ref(false);
const dataFormRef = ref();

const dataForm = reactive({
  id: "",
  exhCode: "",
  exbManagerId: "",
  exhType: "",
  exhIfCompany: "",
  exhGroup: "",
  qtrId: "",
  exhName: "",
  exhIfConfirm: "",
  exhBTime: "",
  exhETime: "",
  exhCity: "",
  exhEhcId: "",
  exhDetail: "",
  exhScope: "",
  exhTrade: "",
  exhTrade1: "",
  exhAcreage: "",
  charProcess: "",
  exhWebUrl: "",
  intCustNumber: "",
  exhRecommend: "",
  exhPriority: "",
  exhLinkInfo: "",
  exhOrgInfo: "",
  exhExtInfo: "",
  exhCreator: "",
  exhSName: "",
  exhEName: "",
  exhCreateTime: "",
  exhHandleTime: "",
  exhIfAudited: "",
  exhClickNum: "",
  exhNumLastMonth: "",
  exhNumLastWeek: "",
  exhOrder: "",
  exhZhichiNum: "",
  exhFanduiNum: "",
  exhLastExhId: "",
  exhStallNum: "",
  exhAttend: "",
  exhSubPlace: "",
  exhProject: "",
  exhMaxCurrentCard: "",
  exhParentId: "",
  exhShowRooms: "",
  exhIfVisit: "",
  exhRemark: "",
  modifierId: "",
  exhOwner: "",
  exhInviteActorOjaId: "",
  exhEsName: "",
  exhActorManagerId: "",
  exhDetailEn: "",
  exhMarOfficerId: "",
  code: "",
  project: "",
  exhFName: "",
  exhSaleAmount: "",
  exhActorCount: "",
  exhBoothCount: "",
  updater: "",
  updateTime: "",
});

const rules = ref({
});

const init = (id?: number) => {
  visible.value = true;
  dataForm.id = "";

  // 重置表单数据
  if (dataFormRef.value) {
    dataFormRef.value.resetFields();
  }

  if (id) {
    getInfo(id);
  }
};

// 获取信息
const getInfo = (id: number) => {
  baseService.get("/crm/crmexhibition/" + id).then((res) => {
    Object.assign(dataForm, res.data);
  });
};

// 表单提交
const dataFormSubmitHandle = () => {
  dataFormRef.value.validate((valid: boolean) => {
    if (!valid) {
      return false;
    }
    (!dataForm.id ? baseService.post : baseService.put)("/crm/crmexhibition", dataForm).then((res) => {
      ElMessage.success({
        message: t("prompt.success"),
        duration: 500,
        onClose: () => {
          visible.value = false;
          emit("refreshDataList");
        }
      });
    });
  });
};

defineExpose({
  init
});
</script>